package com.lemon.smartsafety.ui.activity.fire;

import android.app.Activity;

import com.lemon.smartsafety.R;
import com.lemon.smartsafety.utils.CommonUtil;
import com.lemon.smartsafety.utils.LogUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 项目名称：workspace
 * 类描述：
 * 创建人：Fargo
 * 创建时间：2016/8/15 10:17
 * 修改人：Fargo
 * 修改时间：2016/8/15 10:17
 * 修改备注：
 */
public class FirefightingUtil {


    //指示灯状态：2：红；1：绿；3：黄
    public static int  getScoreTextColor(String status){

        int mColor= R.color.colorAppRed;
        switch (status){
            case "2":
                mColor= R.color.colorAppRed;
                break;
            case "1":
                mColor= R.color.colorAppGreen;
                break;
            case "3":
                mColor= R.color.colorAppYellow;
                break;
            default:
                mColor= R.color.colorTextPrimary;
                break;

        }

        return mColor;
    }


    //指示灯状态：2：红；1：绿；3：黄
    public static int  getScoreTextBgColor(String status){

        int mColor= R.drawable.shape_round_line_red;
        switch (status){
            case "2":
                mColor= R.drawable.shape_round_line_red;
                break;
            case "1":
                mColor= R.drawable.shape_round_line_green;
                break;
            case "3":
                mColor= R.drawable.shape_round_line_yellow;
                break;
            default:
                mColor= R.drawable.shape_round_line_yellow;
                break;

        }

        return mColor;
    }



    //指示灯状态：2：红；1：绿；3：黄
    public static int  getScoreImgCircleColor(String status){

        int mColor= R.drawable.shape_circle_red;
        switch (status){
            case "2":
                mColor= R.drawable.shape_circle_red;
                break;
            case "1":
                mColor= R.drawable.shape_circle_green;
                break;
            case "3":
                mColor= R.drawable.shape_circle_yellow;
                break;
            default:
                mColor= R.drawable.shape_circle_trans;
                break;
        }

        return mColor;
    }


    //指示灯状态：2：红；1：绿；3：黄
    public static int  getCalendarColor(String status){

        int mColor= R.color.calendar_color1;
        switch (status){
            case "1":
                mColor= R.color.calendar_color1;
                break;
            case "2":
                mColor= R.color.calendar_color2;
                break;
            case "3":
                mColor= R.color.calendar_color3;
                break;
            case "4":
                mColor= R.color.calendar_color4;
                break;
            default:
                mColor= R.color.calendar_color4;
                break;
        }

        return mColor;
    }


    /**
     * 获取之前的分数
     * @return
     */
    public static  int getScoreFront(String str){
        int score=0;

        try {
            String strP=str.substring(0,str.indexOf("~"));
            LogUtils.LOGE(str+"     getScoreLater:"+strP);
            score=Integer.valueOf(strP);
        } catch (NumberFormatException e) {
            e.printStackTrace();
            return score;
        }

        return score;
    }


    /**
     * 获取之后的分数
     * @return
     */
    public static  int getScoreLater(String str){
        int score=0;

        try {
            String strP=str.substring(str.indexOf("~")+1,str.length());
            LogUtils.LOGE(str+"     getScoreLater:"+strP);
            score=Integer.valueOf(strP);

        } catch (NumberFormatException e) {
            e.printStackTrace();
            return score;
        }
        return score;
    }







    public static List<Activity> fireInspectActivityList;

    public static void fireInspectAdd(Activity activity){
        if(CommonUtil.listIsEmpty(fireInspectActivityList)){
            fireInspectActivityList=new ArrayList<>();
        }
        fireInspectActivityList.add(activity);

    }


    public static void fireColose(Activity activity){

        for (int i = 0; i < fireInspectActivityList.size(); i++)
        {
            if (null != fireInspectActivityList.get(i))
            {
                fireInspectActivityList.get(i).finish();
            }
        }
        fireInspectActivityList.clear();
      /*  activity.startActivity(new Intent(getActivity(), UserLoginActivity.class)
                .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
        activity.finish();*/

    }




}
